<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <div id="app">
    <div class="nav">
      <router-link to="/">发现音乐</router-link>
      <router-link to="/my">我的音乐</router-link>
      <router-link to="/friend">朋友</router-link>
    </div>
    <!-- 显示一级路由对应组件位置 -->
    <router-view></router-view>
  </div>
  <script src="./vue.js"></script>
  <script src="./vue-router.js"></script>
  <script>

    // 一级路由组件
    const Home = {
      template: `<div>
        <router-link to="/tj">推荐</router-link>
        <router-link to="/bd">榜单</router-link>
        <router-link to="/dj">DJ</router-link>
        <!-- 显示二级路由对应组件位置 -->
        <router-view></router-view>
      </div>` }
    const My = { template: '<div> 我的音乐Content </div>' }
    const Friend = { template: '<div> 发朋友Content </div>' }

    // 二级路由组件
    const Tj = { template: '<div> 推荐LIST </div>' }
    const Bd = { template: '<div> 榜单LIST </div>' }
    const Dj = { template: '<div> DJ-LIST </div>' }

    const routes = [
      {
        path: '/', component: Home, children: [
          { path: '/tj', component: Tj },
          { path: '/bd', component: Bd },
          { path: '/dj', component: Dj }
        ],
      },
      { path: '/my', component: My },
      { path: '/friend', component: Friend }
    ]

    const router = new VueRouter({ routes })

    new Vue({
      el: '#app',
      router
    })
  </script>
</body>

</html>